package com.gjy.kafka.sb.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.*;

/**
 * @author 宫静雨
 * @version 1.0
 * @since 2023-12-23 11:49:33
 */
@RestController
@RequestMapping("/kafka")
public class KafkaController {
    private static final Logger log = LoggerFactory.getLogger(KafkaController.class);

    @Autowired
    private KafkaTemplate<String, String> kafkaTemplate;

    @PostMapping("/send")
    public void send(@RequestBody String msg) {
        kafkaTemplate.send("kk", msg);
        log.info("send ok: {}", msg);
    }
}
